package com.zhouqinuan.spring.cloud.develop.framework.routing.datasource;

import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class RoutingDataSource extends AbstractRoutingDataSource {

    @Override
    protected Object determineCurrentLookupKey() {
        
        if (log.isDebugEnabled()) {
            log.debug("Current DataSource is [{}]", RoutingDataSourceContextHolder.getDataSourceKey());   
        }
        
        return RoutingDataSourceContextHolder.getDataSourceKey();
    }

}
